package com.spring.demo8.eg9;

import org.junit.Test;
import org.springframework.beans.factory.support.AbstractBeanDefinition;
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;

/**
 * @author vhans
 */
public class InitMethodTest {
    @Test
    public void test() {
        DefaultListableBeanFactory factory = new DefaultListableBeanFactory();
        AbstractBeanDefinition service = BeanDefinitionBuilder.genericBeanDefinition(Service.class)
                .setInitMethodName("init")
                .getBeanDefinition();

        factory.registerBeanDefinition("service", service);

        System.out.println(factory.getBean("service"));
    }
}
